package com.cogent.dao;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;

import com.cogent.common.util.Globals;
import com.cogent.dao.facade.BussinessDaoFacade;

public class BussinessInstance {
	public static final String SPRING_CONFIG_XML = Globals.getRootPath() + "WEB-INF/config/spring/applicationContext.xml";
	
	public BussinessDaoFacade getBussinessFacade() {
		Resource resource = new FileSystemResource(SPRING_CONFIG_XML);
		BeanFactory factory = new XmlBeanFactory(resource);
		factory.getBean("dataSource");
		factory.getBean("idgen");
		factory.getBean("sqlBuilder");
		BussinessDaoFacade bussinessFacade = (BussinessDaoFacade)factory.getBean("bussinessFacade");
		
		return bussinessFacade;
	}
}
